package main

import "fmt"

//父结构体
type Animal struct {
	Name string
}

func (a Animal) run() {
	fmt.Printf("%v在运动 \n", a.Name)
}

//子结构体
type Dog struct {
	Age    int
	Animal //结构体嵌套/继承
}

func (d Dog) wang() {
	fmt.Printf("%v在汪汪 \n", d.Name)
}

func main() {
	var d = Dog{
		Age: 3,
		Animal: Animal{
			Name: "王汪汪",
		},
	}

	d.run()  //王汪汪在运动
	d.wang() //王汪汪在汪汪
	fmt.Printf("%#v\n", d)
}
